package com.shop.cloud.common.es.utils;

import co.elastic.clients.elasticsearch._types.mapping.*;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;

/**
 * ElasticSearchMapperBuilder
 *
 * @author
 * @date 2022-08-12 16:25:10
 */
@Slf4j
public class ElasticSearchMapperBuilder {

	/**
	 * goodsSpu Mapper
	 * @return
	 */
	public static Map<String, Property> getGoodsSpuMapper(){
		Map<String, Property> documentMap = new HashMap<>();
		documentMap.put("id", Property.of(property ->
				property.keyword(KeywordProperty.of(keywordProperty ->
						keywordProperty.index(true))
					)
				)
		);
		documentMap.put("tenantId", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("shopId", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("spuCode", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("name", Property.of(property ->
						property.text(TextProperty.of(textProperty ->
								textProperty.index(true).analyzer("ik_max_word"))
						)
				)
		);
		documentMap.put("sellPoint", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(false))
						)
				)
		);
		documentMap.put("description", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(false))
						)
				)
		);
		documentMap.put("categoryFirst", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("categorySecond", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("categoryShopFirst", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("categoryShopSecond", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("picUrls", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(false))
						)
				)
		);
		documentMap.put("shelf", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("sort", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(false))
						)
				)
		);
		documentMap.put("priceDown", Property.of(property ->
						property.double_(DoubleNumberProperty.of(doubleNumberProperty ->
								doubleNumberProperty.index(true))
						)
				)
		);
		documentMap.put("priceUp", Property.of(property ->
						property.double_(DoubleNumberProperty.of(doubleNumberProperty ->
								doubleNumberProperty.index(true))
						)
				)
		);
		documentMap.put("saleNum", Property.of(property ->
						property.integer(IntegerNumberProperty.of(integerNumberProperty ->
								integerNumberProperty.index(true))
						)
				)
		);
		documentMap.put("createTime", Property.of(property ->
						property.date(DateProperty.of(dateProperty ->
								dateProperty.index(false))
						)
				)
		);
		documentMap.put("createTime", Property.of(property ->
						property.date(DateProperty.of(dateProperty ->
								dateProperty.index(false))
						)
				)
		);
		documentMap.put("specType", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("delFlag", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("pointsGiveSwitch", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("pointsGiveNum", Property.of(property ->
						property.integer(IntegerNumberProperty.of(integerNumberProperty ->
								integerNumberProperty.index(false))
						)
				)
		);
		documentMap.put("pointsDeductSwitch", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("pointsDeductScale", Property.of(property ->
						property.integer(IntegerNumberProperty.of(integerNumberProperty ->
								integerNumberProperty.index(false))
						)
				)
		);
		documentMap.put("pointsDeductAmount", Property.of(property ->
						property.double_(DoubleNumberProperty.of(doubleNumberProperty ->
								doubleNumberProperty.index(false))
						)
				)
		);
		documentMap.put("freightTemplatId", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("verifyStatus", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(true))
						)
				)
		);
		documentMap.put("verifyDetail", Property.of(property ->
						property.keyword(KeywordProperty.of(keywordProperty ->
								keywordProperty.index(false))
						)
				)
		);
		return documentMap;
	}
}
